home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / Chip Temmuz 2004.iso / program / code / Adobe Illustrator CS Tryout / data1.cab / Program_Files / Presets / Scripts / ApplyStyleToTextSelection.js < prev    next >
Encoding:
Text File  |  2004-01-07  |  1022 b   |  47 lines

  1. // apply a style to selected text
  2.  
  3.  
  4.  
  5. //$.bp();    //    Uncomment this line to cause the script to be run in the JavaScript debugger window.
  6.  
  7.  
  8.  
  9. ApplyStyle();
  10.  
  11.  
  12.  
  13. function ApplyStyle() 
  14.  
  15. {
  16.  
  17.     selectedItems = selection;
  18.  
  19.  
  20.  
  21.     // check to make sure something is selected.
  22.  
  23.     if (selectedItems.length == 0)
  24.  
  25.     {
  26.  
  27.         alert("Nothing is selected");
  28.  
  29.         return;
  30.  
  31.     }
  32.  
  33.  
  34.  
  35.     endIndex = selectedItems.length;
  36.  
  37.  
  38.  
  39.     for (index = 0; index < endIndex; index++)
  40.  
  41.     {
  42.  
  43.  
  44.  
  45.         pageObject = selectedItems[index];
  46.  
  47.         pageItemType = pageObject.typename;
  48.  
  49.         
  50.  
  51.         if (pageItemType == "TextFrame")
  52.  
  53.         {
  54.  
  55.             theTextRange = pageObject.textRange;
  56.  
  57.             theTextRange.size = 48;
  58.  
  59.  
  60.  
  61.             theGraphicStyles = activeDocument.graphicStyles;
  62.  
  63.  
  64.  
  65.             if (activeDocument.documentColorSpace == DocumentColorSpace.CMYK)
  66.  
  67.             {
  68.  
  69.                 theGraphicStyles = theGraphicStyles[7];
  70.  
  71.                 theGraphicStyles.applyTo(pageObject);
  72.  
  73.             }
  74.  
  75.             else
  76.  
  77.             {
  78.  
  79.                 theGraphicStyles = theGraphicStyles[9];
  80.  
  81.                 theGraphicStyles.applyTo(pageObject);
  82.  
  83.             }
  84.  
  85.         }
  86.  
  87.     }
  88.  
  89. }
  90.  
  91.  
  92.  
  93.